<?php
 include_once 'connection.php';
session_start();
if(!isset($_SESSION['nenunnanu_admin']))
{
header("location:admin_login.php");
}

 if($_POST['type']=='article')
 {
 	$today = time("now");
  $sql= "insert into articles(title,content,insert_date,date_insert,userid) values ('$_POST[title]','$_POST[content]','$today','".date('j/n/Y',$today)."',$_SESSION[nenunnanu_id])";
 }
 else if($_POST['type']=='event')
 {
   $sql= "insert into events(description) values ('$_POST[content]')";
 
 }
else if($_POST['type']=='quote')
 {
   $sql= "insert into quotes(quote,author) values ('$_POST[content]','$_POST[author]')";
 
 }
 else if($_POST['type']=='speak')
 {
   $sql= "insert into donor_speak(speak,donor_name) values ('$_POST[content]','$_POST[name]')";
 
 }
 else if($_POST['type']=='faq')
 {
   $sql= "insert into faq(question,answer) values ('".addslashes($_POST[question])."','".addslashes($_POST[answer])."')";
 
 }
  if(!$res=mysql_query($sql))
  {
    echo mysql_error();
  }
  else
  {
  
 if($_POST['type']=='article')
    header("location:../add_article.php?status=success");
 else if($_POST['type']=='event')
    header("location:../add_event.php?status=success");
  else if($_POST['type']=='quote')
    header("location:../add_quote.php?status=success");   
  else if($_POST['type']=='speak')
    header("location:../add_speak.php?status=success"); 
  else if($_POST['type']=='faq')
    header("location:../add_faq.php?status=success"); 
  }
 
?>